// const baseUrl = "https://m4.xiaoyu.com/index.php/jjd/sendcode";
import API from './config.js'
function sendSMS(params, method, loading, sessionChoose, callBack) {
  if (loading == true) {
    wx.showToast({
      title: '数据加载中',
      icon: 'loading'
    })
  }
  var paramSession = [{},
    {'content-type': 'application/json'},
    {'content-type': 'application/x-www-form-urlencoded'}
  ];
  wx.request({
    url: API.sms,
    data: params,
    dataType: "json",
    header: paramSession[sessionChoose],
    method: method,
    success: function(res) {
      if (loading == true) {
        wx.hideToast(); //隐藏提示框
      }
      callBack(res.data);
    },
    complete: function() {
      if (loading == true) {
        wx.hideToast(); //隐藏提示框
      }
    }
  })
}
module.exports = sendSMS